{template 'web/common/common'}
{template 'web/article/navbar'}
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.css" />
<link rel="stylesheet" type="text/css" href="../addons/kundian_farm/resource/css/layui.css" />
<link rel="stylesheet" type="text/css" href="../addons/kundian_farm/resource/css/new-common.css" />
<blockquote class="layui-elem-quote">
  资讯分类
</blockquote>   
<a href="{url 'site/entry/article',array('m'=>'kundian_farm','op'=>'article_type_edit','version_id'=>$_GPC['version_id'],'cate_id'=>15)}">
	<button class="layui-btn">
	  <i class="layui-icon">&#xe608;</i> 新增分类
	</button>
</a>
<div class="layui-form">
  <table class="layui-table">
   
    <thead>
      <tr>
        <th>ID</th>
        <th>名称</th>
        <th>排序</th>
        <th>操作</th>
      </tr> 
    </thead>
    <tbody>
    {loop $list $index $item}
      <tr>
        <td>{$item['id']}</td>
        <td>{$item['type_name']}</td>
        <td>{$item['rank']}</td>
        <td>
        	<a href="{url 'site/entry/article',array('m'=>'kundian_farm','op'=>'article_type_edit','id'=>$item['id'],'version_id'=>$_GPC['version_id'],'cate_id'=>15)}">
			<button class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe642;</i></button>
        	</a>

		  <button class="layui-btn layui-btn-sm delete" data-id="{$item['id']}">
		    <i class="layui-icon">&#xe640;</i>
		  </button>
        </td>
      </tr>
    {/loop}
    </tbody>
  </table>
</div>

<script>
    require(["../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.js"],function(){
        $(function(){
            //删除
            $(".delete").click(function(){
                var that=$(this);
                var id=$(this).attr('data-id');
                swal({
                    title: '提示',
                    text: "确定删除吗?",
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '删除',
                    cancelButtonText: '取消',
                }).then(function(isConfirm) {
                    if (isConfirm) {
                        $.ajax({
                            type:"post",
                            url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'article_type_delete','version_id'=>$_GPC['version_id'])}",
                            data:{id:id},
                            dataType:'json',
                            success:function(res){
                                if(res.status==1){
                                    swal('操作成功!', '操作成功!', 'success');
                                    that.parent().parent().remove();
                                }else{
                                    swal('操作失败!', '操作失败!', 'error');
                                }
                            }
                        })
                    }
                })
            });
        })
    })
</script>